/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package persistence;

import core.AEntityContentProvider;
import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Date;
import java.util.Set;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Ivan
 */
@Entity
@Table(name = "LEAGUE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "League.findAll", query = "SELECT l FROM League l"),
    @NamedQuery(name = "League.findByLeagueId", query = "SELECT l FROM League l WHERE l.leagueId = :leagueId"),
    @NamedQuery(name = "League.findByName", query = "SELECT l FROM League l WHERE l.name = :name"),
    @NamedQuery(name = "League.findByStatus", query = "SELECT l FROM League l WHERE l.status = :status"),
    @NamedQuery(name = "League.findByDateOfInception", query = "SELECT l FROM League l WHERE l.dateOfInception = :dateOfInception"),
    @NamedQuery(name = "League.findByDateOfEnd", query = "SELECT l FROM League l WHERE l.dateOfEnd = :dateOfEnd")})
public class League  extends AEntityContentProvider<League> implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    //@Basic(optional = false)
    //@NotNull
    @GeneratedValue(generator="CommonSeq", strategy= GenerationType.SEQUENCE)
   // @SequenceGenerator( name="CommonSeq",sequenceName="common_seq", allocationSize=1)
    @Column(name = "LEAGUE_ID")
    private BigDecimal leagueId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 15)
    @Column(name = "NAME")
    private String name;
    @Basic(optional = false)
    @NotNull
    @Column(name = "STATUS")
    private BigInteger status;
    @Column(name = "DATE_OF_INCEPTION")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateOfInception;
    @Column(name = "DATE_OF_END")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateOfEnd;
    @OneToMany(mappedBy = "leagueId")
    private Set<Tournament> tournamentSet;
    @JoinColumn(name = "WINNER_TEAM_ID", referencedColumnName = "TEAM_ID")
    @ManyToOne
    private Team winnerTeamId;
    @JoinColumn(name = "OWNER", referencedColumnName = "SYS_USER_ID")
    @ManyToOne
    private SysUser owner;
    @JoinColumn(name = "DISCIPLINE_ID", referencedColumnName = "DISCIPLINE_ID")
    @ManyToOne
    private Discipline disciplineId;

    public League() {
    }

    public League(BigDecimal leagueId) {
        super(League.class);
        this.leagueId = leagueId;
    }

    public League(BigDecimal leagueId, String name, BigInteger status) {
        super(League.class);
        this.leagueId = leagueId;
        this.name = name;
        this.status = status;
    }

    public BigDecimal getLeagueId() {
        return leagueId;
    }

    public void setLeagueId(BigDecimal leagueId) {
        this.leagueId = leagueId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public BigInteger getStatus() {
        return status;
    }

    public void setStatus(BigInteger status) {
        this.status = status;
    }

    public Date getDateOfInception() {
        return dateOfInception;
    }

    public void setDateOfInception(Date dateOfInception) {
        this.dateOfInception = dateOfInception;
    }

    public Date getDateOfEnd() {
        return dateOfEnd;
    }

    public void setDateOfEnd(Date dateOfEnd) {
        this.dateOfEnd = dateOfEnd;
    }

    @XmlTransient
    public Set<Tournament> getTournamentSet() {
        return tournamentSet;
    }

    public void setTournamentSet(Set<Tournament> tournamentSet) {
        this.tournamentSet = tournamentSet;
    }

    public Team getWinnerTeamId() {
        return winnerTeamId;
    }

    public void setWinnerTeamId(Team winnerTeamId) {
        this.winnerTeamId = winnerTeamId;
    }

    public SysUser getOwner() {
        return owner;
    }

    public void setOwner(SysUser owner) {
        this.owner = owner;
    }

    public Discipline getDisciplineId() {
        return disciplineId;
    }

    public void setDisciplineId(Discipline disciplineId) {
        this.disciplineId = disciplineId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (leagueId != null ? leagueId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof League)) {
            return false;
        }
        League other = (League) object;
        if ((this.leagueId == null && other.leagueId != null) || (this.leagueId != null && !this.leagueId.equals(other.leagueId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "persistence.League[ leagueId=" + leagueId + " ]";
    }
    
}
